package com.example.mydemo02;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.example.mydemo02.databinding.ActivityMain2Binding;

public class MainActivity2 extends AppCompatActivity {
    private ActivityMain2Binding binding;

    @SuppressLint("SetTextI18n")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding=ActivityMain2Binding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        final Intent intent = getIntent();
        final boolean Adata = intent.getBooleanExtra("anserData",true);

        Log.d("`11212121",""+Adata);
        binding.tvAnswer.setText(""+Adata);

        binding.btnAnswer.setOnClickListener(view -> {
            final Intent returnIntent = new Intent();
            returnIntent.putExtra("anserData", "返回给调用的activity的数据");
            setResult(RESULT_OK, returnIntent);
            finish();
        });
    }
}